# https://leetcode-cn.com/problems/unique-binary-search-trees/
# 96. 不同的二叉搜索树

class Solution:
    def numTrees(self, n: int) -> int:
        dp = [0] * (n + 1)
        dp[0] = 1
        # dp[1] = 1
        for i in range(1, n + 1):
            for j in range(1, i + 1):
                dp[i] += dp[j - 1] * dp[i - j]
        # print(dp)
        return dp[n]


a = Solution()
a.numTrees(5)
